
#pragma once

#include <QDialog>
#include "rviz_custom_plugins/widgets/ui_file_transfer_dialog.h"
#include <rviz_common/display_context.hpp>
#include <controller_msgs/srv/file_trans_cmd.hpp>
#include <controller_msgs/srv/file_trans_status.hpp>
#include <cstdint>
#include <QProgressBar>
#include <QHash>


using rviz_common::DisplayContext;
using controller_msgs::srv::FileTransCmd;
using controller_msgs::srv::FileTransStatus;


namespace rviz_custom_plugins
{


namespace widgets 
{


class FileTransferDialog : public QDialog
{
    Q_OBJECT

public:
    explicit FileTransferDialog(QWidget *parent = nullptr);

    void initialize(DisplayContext * context);

    void setTransMode(int transMode);
    void setGroundPath(QString groundPath);
    void setAirPath(QString airPath);

private:

    Ui::fileTransferDialog* ui{ nullptr };

    DisplayContext * context;
    rclcpp::Node::SharedPtr node;

    int transMode;
    QString groundPath;
    QString airPath;
    QString fileMd5;

    rclcpp::Client<FileTransCmd>::SharedPtr fileTransferClient;
    rclcpp::Client<FileTransStatus>::SharedPtr fileTransferQueryClient;

    // 传输请求的hash，key是地面站路径，value是trans_id
    QHash<QString, int16_t> transHash;
    
    void transferQuery(QString transKey);


private slots:
    void startTransfer();



};


}


}